<?php


namespace app\mini\controller\v1\shop;

use app\common\library\MemberVo;
use app\common\logic\RechargeLogic;
use app\mini\controller\Common;
use app\mini\controller\v1\shop\validate\rechargeValidate;
use think\Request;
use think\response\Json;

class Recharge extends Common
{
    public $RechargeLogic;
    public $Validate;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->RechargeLogic = new RechargeLogic();
        $this->Validate = new rechargeValidate();
    }

    public function index(): Json
    {
        $res = $this->exception(function () {
            $params = request()->param();
            $params['shop_id'] = MemberVo::instance()->getShopId();
            $params['field'] = ['id','money','agenttime','platformtime','status','agent_record','platform_record'];
            return $this->RechargeLogic->index($params);
        });
        return $this->response($res);
    }

    /**
     * 商家充值申请
     * @return Json
     */
    public function recharge(): Json
    {
        $res = $this->exception(function () {
            return $this->RechargeLogic->recharge();
        });
        return $this->response($res);
    }

    /**
     * 确认收款
     * @return Json
     */
    public function confirm(): Json
    {
        $res = $this->transException(function () {
            return $this->RechargeLogic->confirm(request()->param());
        });
        return $this->response($res);
    }

    /**
     * 商家充值
     * @return Json
     */
    public function recharges(): Json
    {
        $res = $this->exception(function () {
            return $this->RechargeLogic->recharge();
        });
        return $this->response($res);
    }
}